using System;
using System.Reflection;
using System.Runtime.InteropServices;

namespace Leap
{
	public class Listener : IDisposable
	{
		public delegate void SwigDelegateListener_0(IntPtr arg0);

		public delegate void SwigDelegateListener_1(IntPtr arg0);

		public delegate void SwigDelegateListener_2(IntPtr arg0);

		public delegate void SwigDelegateListener_3(IntPtr arg0);

		public delegate void SwigDelegateListener_4(IntPtr arg0);

		public delegate void SwigDelegateListener_5(IntPtr arg0);

		public delegate void SwigDelegateListener_6(IntPtr arg0);

		public delegate void SwigDelegateListener_7(IntPtr arg0);

		public delegate void SwigDelegateListener_8(IntPtr arg0);

		public delegate void SwigDelegateListener_9(IntPtr arg0);

		public delegate void SwigDelegateListener_10(IntPtr arg0);

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;

		private SwigDelegateListener_0 swigDelegate0;

		private SwigDelegateListener_1 swigDelegate1;

		private SwigDelegateListener_2 swigDelegate2;

		private SwigDelegateListener_3 swigDelegate3;

		private SwigDelegateListener_4 swigDelegate4;

		private SwigDelegateListener_5 swigDelegate5;

		private SwigDelegateListener_6 swigDelegate6;

		private SwigDelegateListener_7 swigDelegate7;

		private SwigDelegateListener_8 swigDelegate8;

		private SwigDelegateListener_9 swigDelegate9;

		private SwigDelegateListener_10 swigDelegate10;

		private static Type[] swigMethodTypes0 = new Type[1]
		{
			typeof(Controller)
		};

		private static Type[] swigMethodTypes1 = new Type[1]
		{
			typeof(Controller)
		};

		private static Type[] swigMethodTypes2 = new Type[1]
		{
			typeof(Controller)
		};

		private static Type[] swigMethodTypes3 = new Type[1]
		{
			typeof(Controller)
		};

		private static Type[] swigMethodTypes4 = new Type[1]
		{
			typeof(Controller)
		};

		private static Type[] swigMethodTypes5 = new Type[1]
		{
			typeof(Controller)
		};

		private static Type[] swigMethodTypes6 = new Type[1]
		{
			typeof(Controller)
		};

		private static Type[] swigMethodTypes7 = new Type[1]
		{
			typeof(Controller)
		};

		private static Type[] swigMethodTypes8 = new Type[1]
		{
			typeof(Controller)
		};

		private static Type[] swigMethodTypes9 = new Type[1]
		{
			typeof(Controller)
		};

		private static Type[] swigMethodTypes10 = new Type[1]
		{
			typeof(Controller)
		};

		public Listener(IntPtr cPtr, bool cMemoryOwn)
		{
			swigCMemOwn = cMemoryOwn;
			swigCPtr = new HandleRef(this, cPtr);
		}

		public static HandleRef getCPtr(Listener obj)
		{
			return obj?.swigCPtr ?? new HandleRef(null, IntPtr.Zero);
		}

		~Listener()
		{
			Dispose();
		}

		public virtual void Dispose()
		{
			lock (this)
			{
				if (swigCPtr.Handle != IntPtr.Zero)
				{
					if (swigCMemOwn)
					{
						swigCMemOwn = false;
						LeapPINVOKE.delete_Listener(swigCPtr);
					}
					swigCPtr = new HandleRef(null, IntPtr.Zero);
				}
				GC.SuppressFinalize(this);
			}
		}

		public Listener()
			: this(LeapPINVOKE.new_Listener(), true)
		{
			SwigDirectorConnect();
		}

		public virtual void OnInit(Controller arg0)
		{
			lock (arg0)
			{
				try
				{
					if (SwigDerivedClassHasMethod("OnInit", swigMethodTypes0))
					{
						LeapPINVOKE.Listener_OnInitSwigExplicitListener(swigCPtr, Controller.getCPtr(arg0));
					}
					else
					{
						LeapPINVOKE.Listener_OnInit(swigCPtr, Controller.getCPtr(arg0));
					}
					if (LeapPINVOKE.SWIGPendingException.Pending)
					{
						throw LeapPINVOKE.SWIGPendingException.Retrieve();
					}
				}
				finally
				{
					arg0.Dispose();
				}
			}
		}

		public virtual void OnConnect(Controller arg0)
		{
			lock (arg0)
			{
				try
				{
					if (SwigDerivedClassHasMethod("OnConnect", swigMethodTypes1))
					{
						LeapPINVOKE.Listener_OnConnectSwigExplicitListener(swigCPtr, Controller.getCPtr(arg0));
					}
					else
					{
						LeapPINVOKE.Listener_OnConnect(swigCPtr, Controller.getCPtr(arg0));
					}
					if (LeapPINVOKE.SWIGPendingException.Pending)
					{
						throw LeapPINVOKE.SWIGPendingException.Retrieve();
					}
				}
				finally
				{
					arg0.Dispose();
				}
			}
		}

		public virtual void OnDisconnect(Controller arg0)
		{
			lock (arg0)
			{
				try
				{
					if (SwigDerivedClassHasMethod("OnDisconnect", swigMethodTypes2))
					{
						LeapPINVOKE.Listener_OnDisconnectSwigExplicitListener(swigCPtr, Controller.getCPtr(arg0));
					}
					else
					{
						LeapPINVOKE.Listener_OnDisconnect(swigCPtr, Controller.getCPtr(arg0));
					}
					if (LeapPINVOKE.SWIGPendingException.Pending)
					{
						throw LeapPINVOKE.SWIGPendingException.Retrieve();
					}
				}
				finally
				{
					arg0.Dispose();
				}
			}
		}

		public virtual void OnExit(Controller arg0)
		{
			lock (arg0)
			{
				try
				{
					if (SwigDerivedClassHasMethod("OnExit", swigMethodTypes3))
					{
						LeapPINVOKE.Listener_OnExitSwigExplicitListener(swigCPtr, Controller.getCPtr(arg0));
					}
					else
					{
						LeapPINVOKE.Listener_OnExit(swigCPtr, Controller.getCPtr(arg0));
					}
					if (LeapPINVOKE.SWIGPendingException.Pending)
					{
						throw LeapPINVOKE.SWIGPendingException.Retrieve();
					}
				}
				finally
				{
					arg0.Dispose();
				}
			}
		}

		public virtual void OnFrame(Controller arg0)
		{
			lock (arg0)
			{
				try
				{
					if (SwigDerivedClassHasMethod("OnFrame", swigMethodTypes4))
					{
						LeapPINVOKE.Listener_OnFrameSwigExplicitListener(swigCPtr, Controller.getCPtr(arg0));
					}
					else
					{
						LeapPINVOKE.Listener_OnFrame(swigCPtr, Controller.getCPtr(arg0));
					}
					if (LeapPINVOKE.SWIGPendingException.Pending)
					{
						throw LeapPINVOKE.SWIGPendingException.Retrieve();
					}
				}
				finally
				{
					arg0.Dispose();
				}
			}
		}

		public virtual void OnFocusGained(Controller arg0)
		{
			lock (arg0)
			{
				try
				{
					if (SwigDerivedClassHasMethod("OnFocusGained", swigMethodTypes5))
					{
						LeapPINVOKE.Listener_OnFocusGainedSwigExplicitListener(swigCPtr, Controller.getCPtr(arg0));
					}
					else
					{
						LeapPINVOKE.Listener_OnFocusGained(swigCPtr, Controller.getCPtr(arg0));
					}
					if (LeapPINVOKE.SWIGPendingException.Pending)
					{
						throw LeapPINVOKE.SWIGPendingException.Retrieve();
					}
				}
				finally
				{
					arg0.Dispose();
				}
			}
		}

		public virtual void OnFocusLost(Controller arg0)
		{
			lock (arg0)
			{
				try
				{
					if (SwigDerivedClassHasMethod("OnFocusLost", swigMethodTypes6))
					{
						LeapPINVOKE.Listener_OnFocusLostSwigExplicitListener(swigCPtr, Controller.getCPtr(arg0));
					}
					else
					{
						LeapPINVOKE.Listener_OnFocusLost(swigCPtr, Controller.getCPtr(arg0));
					}
					if (LeapPINVOKE.SWIGPendingException.Pending)
					{
						throw LeapPINVOKE.SWIGPendingException.Retrieve();
					}
				}
				finally
				{
					arg0.Dispose();
				}
			}
		}

		public virtual void OnServiceConnect(Controller arg0)
		{
			lock (arg0)
			{
				try
				{
					if (SwigDerivedClassHasMethod("OnServiceConnect", swigMethodTypes7))
					{
						LeapPINVOKE.Listener_OnServiceConnectSwigExplicitListener(swigCPtr, Controller.getCPtr(arg0));
					}
					else
					{
						LeapPINVOKE.Listener_OnServiceConnect(swigCPtr, Controller.getCPtr(arg0));
					}
					if (LeapPINVOKE.SWIGPendingException.Pending)
					{
						throw LeapPINVOKE.SWIGPendingException.Retrieve();
					}
				}
				finally
				{
					arg0.Dispose();
				}
			}
		}

		public virtual void OnServiceDisconnect(Controller arg0)
		{
			lock (arg0)
			{
				try
				{
					if (SwigDerivedClassHasMethod("OnServiceDisconnect", swigMethodTypes8))
					{
						LeapPINVOKE.Listener_OnServiceDisconnectSwigExplicitListener(swigCPtr, Controller.getCPtr(arg0));
					}
					else
					{
						LeapPINVOKE.Listener_OnServiceDisconnect(swigCPtr, Controller.getCPtr(arg0));
					}
					if (LeapPINVOKE.SWIGPendingException.Pending)
					{
						throw LeapPINVOKE.SWIGPendingException.Retrieve();
					}
				}
				finally
				{
					arg0.Dispose();
				}
			}
		}

		public virtual void OnDeviceChange(Controller arg0)
		{
			lock (arg0)
			{
				try
				{
					if (SwigDerivedClassHasMethod("OnDeviceChange", swigMethodTypes9))
					{
						LeapPINVOKE.Listener_OnDeviceChangeSwigExplicitListener(swigCPtr, Controller.getCPtr(arg0));
					}
					else
					{
						LeapPINVOKE.Listener_OnDeviceChange(swigCPtr, Controller.getCPtr(arg0));
					}
					if (LeapPINVOKE.SWIGPendingException.Pending)
					{
						throw LeapPINVOKE.SWIGPendingException.Retrieve();
					}
				}
				finally
				{
					arg0.Dispose();
				}
			}
		}

		public virtual void OnImages(Controller arg0)
		{
			lock (arg0)
			{
				try
				{
					if (SwigDerivedClassHasMethod("OnImages", swigMethodTypes10))
					{
						LeapPINVOKE.Listener_OnImagesSwigExplicitListener(swigCPtr, Controller.getCPtr(arg0));
					}
					else
					{
						LeapPINVOKE.Listener_OnImages(swigCPtr, Controller.getCPtr(arg0));
					}
					if (LeapPINVOKE.SWIGPendingException.Pending)
					{
						throw LeapPINVOKE.SWIGPendingException.Retrieve();
					}
				}
				finally
				{
					arg0.Dispose();
				}
			}
		}

		private void SwigDirectorConnect()
		{
			if (SwigDerivedClassHasMethod("OnInit", swigMethodTypes0))
			{
				swigDelegate0 = SwigDirectorOnInit;
			}
			if (SwigDerivedClassHasMethod("OnConnect", swigMethodTypes1))
			{
				swigDelegate1 = SwigDirectorOnConnect;
			}
			if (SwigDerivedClassHasMethod("OnDisconnect", swigMethodTypes2))
			{
				swigDelegate2 = SwigDirectorOnDisconnect;
			}
			if (SwigDerivedClassHasMethod("OnExit", swigMethodTypes3))
			{
				swigDelegate3 = SwigDirectorOnExit;
			}
			if (SwigDerivedClassHasMethod("OnFrame", swigMethodTypes4))
			{
				swigDelegate4 = SwigDirectorOnFrame;
			}
			if (SwigDerivedClassHasMethod("OnFocusGained", swigMethodTypes5))
			{
				swigDelegate5 = SwigDirectorOnFocusGained;
			}
			if (SwigDerivedClassHasMethod("OnFocusLost", swigMethodTypes6))
			{
				swigDelegate6 = SwigDirectorOnFocusLost;
			}
			if (SwigDerivedClassHasMethod("OnServiceConnect", swigMethodTypes7))
			{
				swigDelegate7 = SwigDirectorOnServiceConnect;
			}
			if (SwigDerivedClassHasMethod("OnServiceDisconnect", swigMethodTypes8))
			{
				swigDelegate8 = SwigDirectorOnServiceDisconnect;
			}
			if (SwigDerivedClassHasMethod("OnDeviceChange", swigMethodTypes9))
			{
				swigDelegate9 = SwigDirectorOnDeviceChange;
			}
			if (SwigDerivedClassHasMethod("OnImages", swigMethodTypes10))
			{
				swigDelegate10 = SwigDirectorOnImages;
			}
			LeapPINVOKE.Listener_director_connect(swigCPtr, swigDelegate0, swigDelegate1, swigDelegate2, swigDelegate3, swigDelegate4, swigDelegate5, swigDelegate6, swigDelegate7, swigDelegate8, swigDelegate9, swigDelegate10);
		}

		private bool SwigDerivedClassHasMethod(string methodName, Type[] methodTypes)
		{
			MethodInfo method = base.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, methodTypes, null);
			return method.DeclaringType.IsSubclassOf(typeof(Listener));
		}

		private void SwigDirectorOnInit(IntPtr arg0)
		{
			OnInit(new Controller(arg0, false));
		}

		private void SwigDirectorOnConnect(IntPtr arg0)
		{
			OnConnect(new Controller(arg0, false));
		}

		private void SwigDirectorOnDisconnect(IntPtr arg0)
		{
			OnDisconnect(new Controller(arg0, false));
		}

		private void SwigDirectorOnExit(IntPtr arg0)
		{
			OnExit(new Controller(arg0, false));
		}

		private void SwigDirectorOnFrame(IntPtr arg0)
		{
			OnFrame(new Controller(arg0, false));
		}

		private void SwigDirectorOnFocusGained(IntPtr arg0)
		{
			OnFocusGained(new Controller(arg0, false));
		}

		private void SwigDirectorOnFocusLost(IntPtr arg0)
		{
			OnFocusLost(new Controller(arg0, false));
		}

		private void SwigDirectorOnServiceConnect(IntPtr arg0)
		{
			OnServiceConnect(new Controller(arg0, false));
		}

		private void SwigDirectorOnServiceDisconnect(IntPtr arg0)
		{
			OnServiceDisconnect(new Controller(arg0, false));
		}

		private void SwigDirectorOnDeviceChange(IntPtr arg0)
		{
			OnDeviceChange(new Controller(arg0, false));
		}

		private void SwigDirectorOnImages(IntPtr arg0)
		{
			OnImages(new Controller(arg0, false));
		}
	}
}
